﻿using System;
using System.Threading.Tasks;
using FwProject.Distribution.Dto;
using Abp.Application.Services;
using Microsoft.AspNetCore.Mvc;
using X.PagedList;
using System.Collections.Generic;
using FwProject.Restaurant.Dto;
using FwProject.Core.Distribution;
using FwProject.Core.Restaurant;
using FwProject.Distribution.Dto.Statistics;
using FwProject.TypeNumber.Dto;
using FwProject.Core.SettlementInfoModel;

namespace FwProject.Distribution
{
    public interface IDistributionAppService : IApplicationService
    {
        Task Test();
        /// <summary>
        /// 创建一个配送订单
        /// </summary>
        /// <returns>The create.</returns>
        /// <param name="input">Input.</param>
        Task<Guid> Create(DistributionInpuDto input);
        /// <summary>
        /// 配送中退回回收等
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task BackProduct(List<LoadCarRecoveryDto> input, Guid disId);
        /// <summary>
        /// 创建一个配送订单
        /// </summary>
        /// <returns>The create.</returns>
        /// <param name="input">Input.</param>
        Task Createorder(Guid id, DistributionInpuDto input);
        /// <summary>
        /// 修改一个配送订单
        /// </summary>
        /// <returns>The create.</returns>
        /// <param name="input">Input.</param>
        //Task Update(Guid id, DistributionInpuDto input);

        Task EditDistribution(Guid id, DistributionInpuDto input, long CreatorUserId);
        /// <summary>
        /// 返回一个订单信息
        /// </summary>
        /// <returns>The by identifier async.</returns>
        /// <param name="id">Identifier.</param>
        [HttpGet]
        Task<DistributionDto> GetByIdAsync(Guid id);

        /// <summary>
        /// App获取当前的店存数
        /// </summary>
        /// <param name="Restaurantid"></param>
        /// <returns></returns>
        Task<Tuple<int>> GetSotck(Guid Restaurantid);

        Task EditAppDistribution(EditDistributionInpuDto inputList);
        /// <summary>
        /// 配送时没有添加的配送新型号
        /// </summary>
        /// <param name="disId"></param>
        /// <returns></returns>
        Task<List<TypeNumberInfoDtoDistribution>> GetNotDefaultTypeNumber(Guid disId);

        Task<DistributionDto> GetDistributionDetails(Guid restaurantId);

        Task<List<DistributionDto>> GetDistributionInfoAsync(Guid settlementId);
        /// <summary>
        /// 获取餐厅列表下显示的总对象
        /// </summary>
        /// <returns></returns>
        Task<Tuple<int, int>> GetDistributionInfoAllInfo();
        /// <summary>
        /// 返回该司机下的订单
        /// </summary>
        /// <returns>The paged list async.</returns>
        /// <param name="pageIdx">Page index.</param>
        /// <param name="pageSize">Page size.</param>
        [HttpGet]
        Task<IPagedList<DistributionHistoryDetailsDto>> GetRestaurantByDistributionPagedListAsync(int pageIdx, int pageSize, Guid restaurantId, DateTime? begindateTime, DateTime? enddatetime);
        /// <summary>
        /// 返回该餐厅下配送信息
        /// </summary>
        /// <returns>The restaurant paged list async.</returns>
        /// <param name="pageIdx">Page index.</param>
        /// <param name="pageSize">Page size.</param>
        [HttpGet]
        Task<IPagedList<RestaurantDisDetails>> GetSelfRestaurantByDistributionPagedListAsync(int pageIdx, int pageSize, DateTime? begindateTime, DateTime? enddatetime);

        Task<IPagedList<RestaurantTypeNumberListDto>> GetRestaurantTypeNumberListAsync(int pageIdx, int pageSize);

        [HttpGet]
        Task<IPagedList<DistributionViewDto>> GetPagedListAsync(int pageIdx, int pageSize, DateTime? begindateTime, DateTime? enddatetime);
        /// <summary>
        /// 配送列表导出
        /// </summary>
        /// <returns></returns>
        Task<List<DistributionViewDto>> GetExportDistributionListAsync();

        Task<IPagedList<DistributionDetailsView>> GetDetailsPagedListAsync(int pageIdx, int pageSize, string restaurantName, string platesNumber, /*string ExamineStatus,*/ DateTime? begindateTime, DateTime? enddatetime);

        List<DistributionDetailsView> GetDetailsCount(string restaurantName, string driverName, DateTime? beginTime, DateTime? endTime);

        DistributionDetailsView GetDetailsById(Guid id);

        /// <summary>
        /// 获取配送打印信息(未完成)
        /// </summary>
        /// <param name="id">配送Id</param>
        /// <returns></returns>
        //Task GetPrintOutputDtoAsync(Guid id);

        Task<IPagedList<DistributionDetailsView>> GetSignPagedListAsync(int pageIdx, int pageSize, string restaurantName, string pricestatus, string driverName, DateTime? begindateTime, DateTime? enddatetime);

        Task<List<DistributionDetailsView>> GetExportSignListAsync(string restaurantName, string pricestatus, string driverName, DateTime? beginTime, DateTime? endTime);

        Task<List<DistributionDetailsView>> GetExportDetailsAsync(string restaurantName, string driverName, DateTime? begindateTime, DateTime? enddatetime);
        /// <summary>
        /// 餐厅配送统计
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="restaurantName"></param>
        /// <param name="driverName"></param>
        /// <returns></returns>
        Task<IPagedList<RestaurantDistributionView>> GetRestaurantDistributionAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, string restaurantName, long? driverName);

        Task<List<RestaurantDistributionView>> GetRestaurantDistributionListAsync(DateTime? beginTime, DateTime? endTime, string restaurantName, long? driverName);

        /// <summary>
        /// 司机配送统计
        /// </summary>
        /// <returns></returns>
        Task<IPagedList<RestaurantDistributionView>> GetDriverDistributionAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, long? driverName);

        Task<List<ExportDriverDistributionDto>> GetExportDriverDistributionAsync(DateTime? beginTime, DateTime? endTime, long? driverName);
        /// <summary>
        /// 配送货品统计
        /// </summary>
        /// <returns></returns>
        Task<IPagedList<DistributionTypeNumberReportDto>> GetDistributiondetailsAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, long? driverName);

        Task<List<ExportDistributionTypeNumberDto>> GetExportDistributionDetailsAsync(DateTime? beginTime, DateTime? endTime, long? driverName);

        Task<IPagedList<DistributionLineViewList>> GetLineDistributionAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, Guid? line, string driverName);

        Task<List<DistributionLineViewList>> GetExportLineDistributionAsync(DateTime? beginTime, DateTime? endTime, Guid? line);

        Task<IPagedList<DistributionDiffView>> GetDistributionDiffAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, Guid? line, long? driverName);

        Task<List<DistributionDiffView>> GetExportDistributionDiffAsync(DateTime? beginTime, DateTime? endTime, Guid? LineId, long? DriverId);

        [HttpGet]
        Task SetUpdateOrder(Guid id, Guid setOrderID);
        /// <summary>
        /// 重计金额
        /// </summary>
        /// <param name="id"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        Task RecalculatePrice(Guid id);
        /// <summary>
        /// 获取为支付的配送订单
        /// </summary>
        /// <param name="pageIdx"></param>
        /// <param name="pageSize"></param>
        /// <param name="Restaurantid"></param>
        /// <param name="begindateTime"></param>
        /// <param name="enddatetime"></param>
        /// <returns></returns>
        [HttpGet]
        Task<IPagedList<DistributionDto>> GetPageNotPay(int pageIdx, int pageSize, Guid Restaurantid, DateTime? begindateTime, DateTime? enddatetime);
        [HttpGet]
        Task<IPagedList<DistributionDto>> GetAppPageNotPay(int pageIdx, int pageSize, Guid Restaurantid, DateTime? begindateTime, DateTime? enddatetime);

        [HttpGet]
        /// <summary>
        /// 获取当前餐厅为支付的所有信息
        /// </summary>
        /// <param name="pageIdx"></param>
        /// <param name="pageSize"></param>
        /// <param name="begindateTime"></param>
        /// <param name="enddatetime"></param>
        /// <returns></returns>
        Task<IPagedList<DistributionDto>> GetSelfRestaurantByDistributionNotPayPagedListAsync(int pageIdx, int pageSize, Guid restaurantId, DateTime? begindateTime, DateTime? enddatetime);

        /// <summary>
        /// 获取餐厅的所有为配送的信息
        /// </summary>
        /// <returns></returns>
        Task<List<SelfRestaurantEnterDto>> GetSelfRestaurantEnter();

        /// <summary>
        /// 餐厅配送状态修改默认是修改成未结账
        /// </summary>
        /// <returns></returns>
        Task EditStatusEnter(List<DistributionUpdateStatusDto> dto);

        /// <summary>
        ///根据司机编号查询出司机的配送明细
        /// </summary>
        /// <param name="Driverid"></param>
        /// <param name="BeginTime"></param>
        /// <param name="EndTime"></param>
        /// <returns></returns>
        Task<List<DistributionDto>> GetDriverByRestaurant(long Driverid, DateTime? BeginTime, DateTime? EndTime);


        /// <summary>
        /// 商家查询自己的配送详情
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageseize"></param>
        /// <returns></returns>
        Task<List<CarShopInfo>> GetSelfRestaurantSelRept(int page, int pageseize, Pricestatus pricestatus, Guid? settlementInfoId, DateTime? beginTime, DateTime? endTime);

        Task<IPagedList<ReceivableDto>> GetReceivableListAsync(int page, int pagesize, string name, string driverName, DateTime? beginTime, DateTime? endTime);

        Task<IPagedList<NotReceivableDto>> GetNotReceivableRestaurantAsync(int pageIdx, int pageSize, string RestaurantName);

        Task<List<NotReceivableDto>> GetNotReceivableListAsync(string RestaurantName);


        Task<ReceivableNewSummaryDto> GetReceivableAsync(int page, int pagesize, string restaurantName, string driverName, DateTime? beginTime, DateTime? endTime,DateTime? beginDate,DateTime? endDate, RestaurantPayStatus? RestaurantPayStatus, BalanceWayEnum? BalanceWayEnum);

        Task<List<ReceivableNewOutputDto>> GetExportReceivableAsync(string restaurantName, string driverName, DateTime? beginTime, DateTime? endTime, DateTime? beginDate, DateTime? endDate, RestaurantPayStatus? RestaurantPayStatus, BalanceWayEnum? BalanceWayEnum);

        Task<Tuple<CarShopInfo, List<AppTopRestaurantDto>>> GetSelRept();

        /// <summary>
        /// 配送单导出
        /// </summary>
        /// <returns></returns>
        Task<List<DistributionDetailsListViewDto>> GetDetailsListAsync(string restaurantName, string driverId, DateTime? beginTime, DateTime? endTime);

        #region 配送报表
        /// <summary>
        /// 配送商品统计
        /// </summary>
        /// <param name="beginTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="productName">商品名称</param>
        /// <param name="restaurant">餐厅</param>
        /// <returns></returns>
        Task<List<DistributionProductStatisticsDto>> GetDistributionProductStatisticsAsync(DateTime? beginTime, DateTime? endTime, string productName, string restaurant);

        /// <summary>
        /// 配送情况
        /// </summary>
        /// <param name="restaurantName">餐厅名称</param>
        /// <returns></returns>
        Task<DeliverySituationDto> GetDeliverySituationAsync(string restaurantName);

        /// <summary>
        /// 配送情况-详情
        /// </summary>
        /// <param name="ramge"></param>
        /// <returns></returns>
        Task<IPagedList<DeliverySituationDetailsDto>> GetDeliverySituationDetailsAsync(int pageIdx, int pageSize, DeliveryTimeRange ramge);

        /// <summary>
        /// 当季汇总
        /// </summary>
        /// <returns></returns>
        Task<QuarterlySummaryDto> GetQuarterlySummary();

        /// <summary>
        /// 当季汇总-月详情
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        Task<List<QuarterlySummaryMonthDto>> GetQuarterlySummaryMonthData(DateTime time);


        /// <summary>
        /// 当季汇总-日详情
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        Task<List<QuarterlySummaryDayDto>> GetQuarterlySummaryDayData(DateTime time, string type);

        /// <summary>
        /// 司机实送率统计
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        Task<DriverActualRatioTotalDto> GetDriverActualRatioAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, long? keyword);
        /// <summary>
        /// 司机实送率统计导出
        /// </summary>
        /// <returns></returns>
        Task<List<DriverActualRatioOutputDto>> GetExportDriverActualRatioAsync(DateTime? beginTime, DateTime? endTime, long? keyword);

        /// <summary>
        /// 时间配送总报表图
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        Task<List<MonthReportChartOutputDto>> GetDistributionReportChart(DateTime time, DateSearchType type);

        /// <summary>
        /// 类型配送报表图
        /// </summary>
        /// <param name="time"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        Task<List<TypeReportChartOutputDto>> GetTypeDistributionReportData(DateTime time, DateSearchType type);

        /// <summary>
        /// 司机配送报表图
        /// </summary>
        /// <param name="time"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        Task<List<DriverReportChartOutputDto>> GetDriverDistributionReportData(DateTime time, DateSearchType type);

        /// <summary>
        /// 配送与回收报表图
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        Task<List<DistributionAndRecyclingOutputDto>> GetDistributionAndRecyclingReportData(DateTime time, DateSearchType type);

        /// <summary>
        /// 配送与回收报表图按司机
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        Task<List<DistributionAndRecyclingOutputDto>> GetDistributionAndRecyclingByDriverReportData(DateTime time);

        /// <summary>
        /// 主页每日统计
        /// </summary>
        /// <returns></returns>
        Task<HomeTodayStatisticsOutputDto> GetHomeTodayStatistics();

        #endregion

        #region 获取可生成收据信息
        Task<IPagedList<GenerateReceiptOutputDto>> GetGenerateReceiptListAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, string restaurantName, long? driverId, Guid? Line2);

        Task<List<GenerateReceiptOutputDto>> GetExportGenerateReceiptListAsync(DateTime? beginTime, DateTime? endTime, string restaurantName, long? driverId, Guid? Line2);

        Task<List<MakingReceiptOutputDto>> GetMakingReceiptsAsync(Guid? driverLine, string ids, DateTime beginTime, DateTime endTime, int type = 0,long driverId=0,string remarks = "");
        #endregion

        Task<TotalSummaryReceivableDto> GetSummaryReceivablePagesListAsync(int pageIdx, int pageSize, DateTime? beginTime, DateTime? endTime, long? DriverId, Guid? Line, RestaurantPayStatus? PayStatus, BalanceWayEnum? WayEnum, string keyword);
        /// <summary>
        /// 应收汇总导出
        /// </summary>
        /// <returns></returns>
        Task<List<SummaryReceivableOutputDto>> GetExportSummaryReceivableListAsync(DateTime? beginTime, DateTime? endTime, long? DriverId, Guid? Line, RestaurantPayStatus? PayStatus, BalanceWayEnum? WayEnum, string keyword);
    }
}
